#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int main()
{
    pid_t pid = fork();
    //子进程
    if(pid==0)
    {
        int cnt = 5;
        while(cnt--)
        {
            printf("这是子进程，pid:%d,cnt:%d\n",getpid(),cnt);
            sleep(2);
        }
    }
    else
    {
        //父进程
        while(1)
        {
            printf("这是父进程，pid:%d\n",getpid());
            sleep(1);
        }
    }

    return 0;
}
